package org.imdm.portal.loadchecker.telnet;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class HostConfig {

	private List hosts = new ArrayList();

	public HostConfig(File file){
		BufferedReader  br = null;
		try {
			br = new BufferedReader(new FileReader(file));
			if(br!=null){
				String line = null;
				try {
					while ((line = br.readLine()) != null){
						if(!line.startsWith("#")&&line.trim().length()!=0)
							hosts.add(line.trim());
					}
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		} catch (FileNotFoundException e) {
			System.err.println("ERROR: Configure file "+file.getAbsolutePath()+" is not found");
		}finally{
			if(br!=null){
				try {
					br.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}

	}

	public HostConfig(List hosts){
		this.hosts = hosts;
	}

	public List getHosts(){
		return hosts;
	}

}
